<script setup lang="ts">
import { ref } from 'vue'
import { groupList } from '../api/group'

const page = ref(1)
const size = ref(10)
const groupId = defineModel()
const options = ref()

const getGroup = async() => {
  let res2 = await groupList(page.value,size.value,'')
  console.log(res2.data.list)
  options.value = res2.data.list.map((item: { name: any; id: any; }) => ({
    value: item.id,
    label: item.name
  }))
}
getGroup()

const emit = defineEmits(['select-group'])
const selectGroup = () => {
    emit('select-group')
}
</script>
<template>
    <el-select
      v-model="groupId"
      placeholder="请选择分组"
      style="width: 200px"
      @change="selectGroup()"
    >
      <el-option
        v-for="item in options"
        :key="item.value"
        :label="item.label"
        :value="item.value"
      />
    </el-select>
</template>